package com.mokio.service.impl;

import com.mokio.entity.Admin;
import com.mokio.entity.AdminExample;
import com.mokio.mapper.AdminMapper;
import com.mokio.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: xiaomishop
 * @ClassName AdminServiceImpl
 * @description:
 * @author: mokio
 * @create: 2024−12-10 16:34
 * @Version 1.0
 **/
@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public String login(String username, String password) {

        //登录标志，标志是否登录成功
        String loginFlag = "no";
        //创建查找帮助类示例
        AdminExample example = new AdminExample();
        //将名字传入到example中
        example.createCriteria().andANameEqualTo(username);
        //根据用户名查找
        List<Admin> admins = adminMapper.selectByExample(example);
        if (admins.size() > 0) {
            loginFlag = "yes";
        }
        return loginFlag;
    }
}
